var triangleCoords = [];    
/** 
 * 根据城市名描画边界范围 
 * @author:wangyq 
 * @parameters:name，区划名，比如广东省或者东莞市 
 */  
function makeBoundsByRegion(name){  
    //下面这句是调用百度API  
    var bdary = new BMap.Boundary();   
    var polygonArray = [];  
    triangleCoords.length=0;  
    bdary.get(name, function(rs) {  
         points = rs; //获取行政区域    
         var rslength = rs.boundaries.length;     
         var components = new Array();  
         var polygon = null;  
         for (i = 0; i < rslength; i++) {    
             var temp = rs.boundaries[i];    
             //一个temp代表一个polygon，部分区域譬如广东省边界范围中包含多个polygon，需要递归画出来  
             var latLngs = temp.split(";");    
             triangleCoords.length = 0;  
             for (j = 1; j < latLngs.length - 1; j++) {   
                 var postion = latLngs[j].indexOf(",");    
                 var lng = parseFloat(latLngs[j].substr(0, postion));//经度    
                 var lat = parseFloat(latLngs[j].substr(postion + 1));//纬度    
                 triangleCoords.push(new OpenLayers.Geometry.Point(lng,lat));    
             }  
             var k = triangleCoords.length;  
             var line = new OpenLayers.Geometry.LinearRing(triangleCoords);  
             polygon = new OpenLayers.Geometry.Polygon([line]);  
             polygonArray.push(polygon);  
         }  
         var MultiPolygon = new OpenLayers.Geometry.MultiPolygon(polygonArray);  
         var polygonBounds = new OpenLayers.Feature.Vector(MultiPolygon);  
         //设置layersname为行政边界的图层的样式  
         if(map.getLayersByName("行政边界").length==0){  
             var sketchStyle = new OpenLayers.Style(null, {  
                 rules: [  
                         new OpenLayers.Rule({  
                             symbolizer: {  
                                 "Polygon": {  
                                     strokeWidth: 3.5,  
                                     strokeOpacity: 1,  
                                     strokeColor: "#FF3366",  
                                     fillColor: "#ff0000",  
                                     fillOpacity: 0  
                                 }  
                             }  
                         })  
                         ]  
             });  
             var myStyle = new OpenLayers.StyleMap({   
                 "default":sketchStyle  
             });  
             var bouderLayer = new OpenLayers.Layer.Vector("行政边界",{  
                 styleMap: myStyle,  
                 projection:WGS84  
             });  
             bouderLayer.addFeatures(polygonBounds);  
             map.addLayer(bouderLayer);  
               
         }else{  
             map.getLayersByName("行政边界")[0].removeAllFeatures();  
             map.getLayersByName("行政边界")[0].addFeatures(polygonBounds);  
         }  
         var centroid = new OpenLayers.LonLat.fromString(MultiPolygon.getCentroid().x+","+MultiPolygon.getCentroid().y);  
         map.moveTo(centroid);  
    });  
} 


//openlayer 地图制定位置显示图片
	function createStyle(src, img,anchor) {
	    return new ol.style.Style({
	      image: new ol.style.Icon(/** @type {olx.style.IconOptions} */ ({
	        anchor: anchor,
	        crossOrigin: 'anonymous',
	        src: src,
	        img: img,
	        imgSize: img ? [img.width, img.height] : undefined
	      }))
	    });
	  }